package designpattern.adapter.springmvc;

public interface HandlerAdapter {
    //支持某种Controller就返回true
    public boolean supports(Controller controller);

    //执行controller的方法
    public void handle(Controller controller);
}

class SimpleHandlerAdapter implements HandlerAdapter{
    @Override
    public boolean supports(Controller controller) {
        if(controller instanceof SimpleController){
            return true;
        }
        return false;
    }

    @Override
    public void handle(Controller controller) {
        controller.print();
    }
}

class HttpHandlerAdapter implements HandlerAdapter{
    @Override
    public boolean supports(Controller controller) {
        if(controller instanceof HttpController){
            return true;
        }
        return false;
    }

    @Override
    public void handle(Controller controller) {
        controller.print();
    }
}

class AnnotationHandlerAdapter implements HandlerAdapter{
    @Override
    public boolean supports(Controller controller) {
        if(controller instanceof AnnotationController){
            return true;
        }
        return false;
    }

    @Override
    public void handle(Controller controller) {
        controller.print();
    }
}
